package demo3;

/**
 * @Author 12629
 * @Date 2022/5/10 19:47
 * @Description：
 */
class Student {
    //普通成员变量
    public String name;
    public double score;
    public int age;

    //静态成员变量[类变量]：不属于对象
    public static  String classes = "105Java" ;//班级

    static {
        classes = "106Java";
        System.out.println("静态代码块！");
    }

    {
        this.name = "bit";
        System.out.println("实例代码块！");
    }

    //Student this,  这里比较特殊
    public Student(String name, double score, int age) {
        this.name = name;
        this.score = score;
        this.age = age;
        System.out.println("带有3个参数的构造方法执行了！");
    }

    public void goClass() {
        System.out.println(this);
        System.out.println(name+"上课！");
        //classes = "106Java";//可以
    }

    public void func(int a) {
        System.out.println(a);
        System.out.println(this.name);
        {
            System.out.println("本地代码块！");
        }
    }

    // 静态的方法当中 不能直接访问非静态的数据  类方法
    public static void staticFunc() {
       // System.out.println(this);
        //this.name = "fdsafsa";//静态方法 不依赖于对象 ，而name是依赖于对象的
        System.out.println("这是一个静态的方法！-》类方法");
        /*Student student = new Student("gaobo",59.9,18);*/
        //student.name = "fsa";
    }
}

public class Test {

    public static void main3(String[] args) {
        System.out.println(Student.classes);

    }

    public static void main(String[] args) {
        Student student = new Student("gaobo",59.9,18);
        System.out.println("=====================");
        Student student2 = new Student("oldbaby",99.9,28);
    }


    public  void function() {

    }

    public static void main2(String[] args) {
        System.out.println(Student.classes);
        Student.staticFunc();
        Test test = new Test();
        test.function();
    }

    public static void main1(String[] args) {
        Student student = new Student("gaobo",59.9,18);
        System.out.println(student.name);
        student.goClass();



        Student student2 = new Student("oldbaby",99.9,28);
        System.out.println("====");
    }
}
